#ifndef _SPI_H_
#define _SPI_H_


#define SPI_DDR	 DDRB
#define SPI_SCK	 PB1
#define SPI_MOSI PB2
#define SPI_MISO PB3


#define SPI_PORT_INIT	SPI_DDR|=1<<SPI_SCK|1<<SPI_MOSI; SPI_DDR&=~(1<<SPI_MISO);

#define SPI_PORT_INIT_BUG	SPI_DDR|=1<<SPI_SCK|1<<SPI_MISO;
#define SPI_OFF_BUG			SPI_DDR&=~(1<<SPI_MISO)

#define MOSI_1 PORTB|=1<<SPI_MOSI
#define MOSI_0 PORTB&=~(1<<SPI_MOSI)


#define MOSI_1_BUG PORTB|=1<<SPI_MISO
#define MOSI_0_BUG PORTB&=~(1<<SPI_MISO)


#define SCK_1 PORTB|=1<<SPI_SCK
#define SCK_0 PORTB&=~(1<<SPI_SCK)

#define SPI_DISABLE	SPCR&=~(1<<SPE)

void Init_SPI(unsigned char conf,unsigned char speed);
void ReInit_SPI(unsigned char conf,unsigned char speed);
unsigned char transmit_spi(unsigned char byte);

#endif
